//package group.raber.jeki.autoconfigure.mybatis;
//
//import group.raber.jeki.autoconfigure.JekiConfiguration;
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.mybatis.spring.SqlSessionFactoryBean;
//import org.mybatis.spring.SqlSessionTemplate;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.autoconfigure.AutoConfigureAfter;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.env.Environment;
//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
//import org.springframework.transaction.PlatformTransactionManager;
//import org.springframework.transaction.annotation.EnableTransactionManagement;
//import org.springframework.transaction.annotation.TransactionManagementConfigurer;
//
//import javax.sql.DataSource;
//
///**
// * MyBatis基础配置
// *
// * @author liuzh
// * @since 2015-12-19 10:11
// */
//@Configuration
//@EnableTransactionManagement
//@AutoConfigureAfter(JekiConfiguration.class)
//public class MyBatisConfig implements TransactionManagementConfigurer {
//
//    @Autowired
//    private Environment env;
//
////    @Autowired
////    private DataSource dataSource;
//
//    /**
//     * 根据数据源创建SqlSessionFactory
//     */
//    @Bean
//    public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception{
//        SqlSessionFactoryBean fb = new SqlSessionFactoryBean();
//        fb.setDataSource(dataSource);//指定数据源(这个必须有，否则报错)
//        //下边两句仅仅用于*.xml文件，如果整个持久层操作不需要使用到xml文件的话（只用注解就可以搞定），则不加
//        fb.setTypeAliasesPackage(env.getProperty("mybatis.typeAliasesPackage"));//指定基包
//        fb.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(env.getProperty("mybatis.mapperLocations")));/定xml文件位置
//
//        return fb.getObject();
//    }
//
////    @Bean(name = "sqlSessionFactory")
////    public SqlSessionFactory sqlSessionFactoryBean()  {
////        SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
////        bean.setDataSource(dataSource);
////        bean.setTypeAliasesPackage("tk.mybatis.springboot.model");
////
//////        //分页插件
//////        PageHelper pageHelper = new PageHelper();
//////        Properties properties = new Properties();
//////        properties.setProperty("reasonable", "true");
//////        properties.setProperty("supportMethodsArguments", "true");
//////        properties.setProperty("returnPageInfo", "check");
//////        properties.setProperty("params", "count=countSql");
//////        pageHelper.setProperties(properties);
////
////        //添加插件
//////        bean.setPlugins(new Interceptor[]{pageHelper});
////
//////        //添加XML目录
//////        ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
//////        try {
//////            bean.setMapperLocations(resolver.getResources("classpath:mapper/*.xml"));
//////            return bean.getObject();
//////        } catch (Exception e) {
//////            e.printStackTrace();
//////            throw new RuntimeException(e);
//////        }
////
////        try {
////            return bean.getObject();
////        } catch (Exception e) {
////            throw new RuntimeException(e);
////        }
////    }
//
//    @Bean
//    public SqlSessionTemplate sqlSessionTemplate(SqlSessionFactory sqlSessionFactory) {
//        return new SqlSessionTemplate(sqlSessionFactory);
//    }
//
//
//    @Bean
//    @Override
//    public PlatformTransactionManager annotationDrivenTransactionManager() {
//        return new DataSourceTransactionManager(dataSource);
//    }
//}